package com.guochenglang.www.util.error;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @author GuoChenglang
 */
public class MyExceptionHandler implements Thread.UncaughtExceptionHandler {
    private static final Logger LOGGER = LogManager.getLogger(MyExceptionHandler.class);

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        LOGGER.info("发生错误！发生的异常为：{}", e.toString(), e);
    }

    public static void registerHandler(){
        Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler());
    }
}
